package org.apache.flink.runtime.resourcemanager;

import java.util.UUID;

import org.apache.flink.api.common.ConsumerID;
import org.apache.flink.runtime.resourceconsumer.ConsumingMasterId;

/** Interface for actions called by the {@link DefaultJobLeaderIdService}. */
public interface ConsumerLeaderIdActions {

    /**
     * Callback when a monitored job leader lost its leadership.
     *
     * @param jobId identifying the job whose leader lost leadership
     * @param oldJobMasterId of the job manager which lost leadership
     */
    void jobLeaderLostLeadership(ConsumerID jobId, ConsumingMasterId oldJobMasterId);

    /**
     * Notify a job timeout. The job is identified by the given JobID. In order to check for the
     * validity of the timeout the timeout id of the triggered timeout is provided.
     *
     * @param jobId JobID which identifies the timed out job
     * @param timeoutId Id of the calling timeout to differentiate valid from invalid timeouts
     */
    void notifyJobTimeout(ConsumerID jobId, UUID timeoutId);

    /**
     * Callback to report occurring errors.
     *
     * @param error which has occurred
     */
    void handleError(Throwable error);
}
